from defect import Defect

__author__ = 'romilly'

class AbstractColumnModel(object):
    def __init__(self, name):
        self._name = name

    def name(self):
        return self._name

    def columnSpecification(self):
        raise Defect('should be implemented by subclass')

class StringColumnModel(AbstractColumnModel):
    def __init__(self, name, size=None):
        super(StringColumnModel, self).__init__(name)
        self._size= size

    def size(self):
        return self._size

    def columnSpecification(self):
        return '%s VARCHAR(%d)' % (self.name(), self.size())

class DateColumnModel(AbstractColumnModel):
    def __init__(self, name):
        super(DateColumnModel, self).__init__(name)

    def columnSpecification(self):
        return '%s DATE' % self.name()

class DecimalColumnModel(AbstractColumnModel):
    def __init__(self, name, size, precision):
        super(DecimalColumnModel, self).__init__(name)
        self._size = size
        self._precision = precision

    def size(self):
        return self._size

    def precision(self):
        return self._precision

    def columnSpecification(self):
        return '%s DECIMAL(%s, %s)' % (self.name(), self.size(), self.precision())

class IntegerColumnModel(AbstractColumnModel):
    def __init__(self, name, size):
        super(IntegerColumnModel, self).__init__(name)
        self._size = size

    def size(self):
        return self._size

    def columnSpecification(self):
        return '%s INTEGER(%s)' % (self.name(), self.size())





  